#include<bits/stdc++.h>
using namespace std;

long long n,m,L,V,p[100005];
double l[100005],r[100005];
struct node{
    int lp,rp;
}c[100005];
int findl(double x) {
    int ll=1,rr=m,mid;
    while(ll<rr) {
        mid=(ll+rr)/2;
        if(x>p[mid]) ll=mid+1;
        else rr=mid;
    }
    return ll;
} 
int findr(double x) {
    int ll=1,rr=m,mid;
    while(ll<rr) {
        mid=(ll+rr+1)/2;
        if(x<p[mid]) rr=mid-1;
        else ll=mid;
    }
    return ll;
}
bool cmp(node a,node b) {
    return a.rp<b.rp;
}
void work() {
    memset(c,0,sizeof(c));
    cin>>n>>m>>L>>V;
    double d,v,a;
    for(int i=1;i<=n;i++) {
        l[i]=0;
        r[i]=0;
        cin>>d>>v>>a;
        if(a==0) {
            if(v>V) {
                l[i]=d;
                r[i]=L;
            }
        } else if(a>0) {
            if(v>V) {
                l[i]=d;
                r[i]=L;
            } else if(v*v+2*a*(L-d)>V) {
                l[i]=(V*V-v*v)/a/2+d+0.0001;
                r[i]=L;
            }
        } else {
            if(v>V) {
                l[i]=d;
                r[i]=d+(V*V-v*v)/a/2-0.0001;
            }
        }
    }
    for(int i=1;i<=m;i++) cin>>p[i];
    int ans1=0,ans2=0;
    for(int i=1;i<=n;i++) {
        if(r[i]<p[1]||l[i]>p[m]) continue;
        else {
            c[i].lp=findl(l[i]);
            c[i].rp=findr(r[i]);
            if(c[i].lp>c[i].rp) {
                c[i].lp=0;
                c[i].rp=0;
                continue;
            }
            ans1++;
        }
    }
    sort(c+1,c+n+1,cmp);
    int rr=0;
    for(int i=1;i<=n;i++) {
        if(c[i].lp>rr) {
            rr=c[i].rp;
            ans2++;
        }
    }
    cout<<ans1<<' '<<m-ans2<<"\n";
}
int main() {
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin>>t;
    while(t--) work();
    return 0;
}